﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Portal
{
    public class CategoryCache
    {


        public static IList<ICategory> GetList()
        {
            IList<ICategory> list;
            if (!Cache.TryGet(CacheKey.CategoryList, out list))
            {
                var categoryRepository = IoC.Resolve<ICategoryRepository>();
                list = categoryRepository.Get().OrderBy(o => o.Sort).ToList();
                Cache.Set(CacheKey.CategoryList, list);
            }
            return list;
        }
        public static string CategoryName(string id)
        {
            var model = GetList().SingleOrDefault(o => o.Id == id);
            if (model != null) return model.Name;
            return "";
        }
    }
}
